<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
    require_once("class.connectSQL.inc");
    
    //instancia da classe
    $banco = new connectSQL();
	$banco1 = new connectSQL();
	$banco2 = new connectSQL();
	$banco3 = new connectSQL();
	$banco4 = new connectSQL();
	$banco5 = new connectSQL();
	
	if(isset($_GET["excluir"])){
				$sql = "Delete from estlote where codLote= ".$_GET["cod"]." ";
				//die($sql);
				
				$banco3->Generico($sql);
				//die($_POST["acao"]);
				$msg = "Excluido com sucesso";
				$where = " LIMIT 0, 0";
			}
?>

	<head>
		<?php include "head.php"; ?>
         <script>   
    function validar(form){
       return true;
	}
  </script>   
	</head>
	<body>
    <form action="">
                        <table width="70%" class="tablesorter" id="myTable">
                        	
                                <tr>
                                   <th width="4%" style="width:5%">#</th>
                                   <th width="9%" style="width:10%">Código Lote</th>
                                   <th width="9%" style="width:10%">Data do Lote</th>
                                   <th width="9%" style="width:10%">Data do Vencimento</th>
                                   <th width="36%" style="width:30%">Produto</th>
                                   <th width="10%" style="width:10%">Quantidade</th>
                                   <th width="10%" style="width:10%">Status</th>
                                   <th width="23%" style="width:35%"></th>
                                </tr>
    <?php
						
						if(isset($_GET["lote"])){
							if($_GET["lote"]<>""){
								$where = " where codLote in  (".$_GET["lote"].")";
								}else{
									$where = "";
									}
							}
				$resultado = $banco2->Query("SELECT A.quantLote, A.dataVencLote,DATEDIFF(A.dataVencLote, DATE(NOW()) ) as status, A.dataLote, A.codLotep, A.codNota, A.codProd, A.codLote, (
								SELECT B.desProd
								FROM estprod AS B
								WHERE B.codProd = A.codProd
								) AS produto
								FROM estlote AS A ".$where);
		 
                           
    								
        foreach ($resultado as $resut){
		
        echo "<tr>";
		
		echo "<td>". $resut['codLote']."</td>";
		echo "<td>". $resut['codLotep']."</td>";
		echo "<td>".implode("/",array_reverse(explode("-",$resut['dataLote'])))."</td>";
		echo "<td>".implode("/",array_reverse(explode("-",$resut['dataVencLote'])))."</td>";
		echo "<td>". $resut['produto']."</td>";
		echo "<td>". $resut['quantLote']."</td>";
		
		
		echo "<td>";
		
		if($resut['status']>=0){
			echo "<font style='color:#0C3'> Válido até ".$resut['status']." dias</font>";
			}else{
				echo "<font style='color:#F60;'> Inválido a ".($resut['status']*-1)." dias</font>";
				}
		
		echo"</td>";
		?>
        <td>
        
        <?php echo "</tr>";
		
		}
		
		
		
   		                  ?>  
                                
                     
                      </tbody>    
                           
                        </table>
                        
                      
                        </form>
                     
                     
                 </div>    
                     
                     
           
	</body>
</html>